var express = require("express");
var router = express.Router();

// 登录和注册
router.post("/login", function (req, res, next) {
  const { username, password } = req.body;

  if (!username || !password) {
    res.json({
      success: false,
      msg: "参数错误",
    });
  } else {
    if (username === "admin" && password === "123456") {
      res.json({
        success: true,
        msg: "登录成功",
        token: "821cef",
        username: "admin",
      });
    } else {
      res.json({
        success: false,
        msg: "账号或者密码错误",
      });
    }
  }
});

module.exports = router;
